package com.superhelper.printer.config;

import java.util.Collections;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.superhelper.common.Consts;
import com.superhelper.printer.task.TaskDispatcher;
import com.superhelper.printer.task.TaskListener;
import com.superhelper.printer.task.TaskThreadPool;

@Configuration

public class TaskConfiguration {

    @Bean(initMethod = "init")
    public TaskDispatcher taskDispatcher() {
        TaskDispatcher td = new TaskDispatcher();
        td.setPoolMapping(Collections.singletonMap(Consts.Task.print, new TaskThreadPool(10, "task.pool.print")));
        return td;
    }

    @Bean(initMethod = "init")
    public TaskListener taskListener() {
        TaskListener td = new TaskListener();
        return td;
    }

}
